package com.ficus.road.maintain.controller;

import com.ficus.road.maintain.core.dto.weather.WeatherSearchResponse;
import com.ficus.road.maintain.service.WeatherSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WeatherController {
    @Autowired
    private WeatherSearchService weatherSearchService;

    @RequestMapping(value = "/weather/search",
            produces = {"application/json"},
            method = RequestMethod.GET)
    public ResponseEntity<WeatherSearchResponse> weatherSearch(@RequestParam(required = true) long time) {
        return new ResponseEntity<>(weatherSearchService.getWeatherInfo(time), HttpStatus.OK);
    }
}
